﻿using System.Web.Mvc;
using Xoohoo.Models.ViewModels;

namespace Xoohoo.Html
{
    public static class AntiForgeryTokenExtensions
    {
        #region AntiForgeryToken

        public static MvcHtmlString XoohooAntiForgeryToken<TModel>(this HtmlHelper<TModel> htmlHelper) where TModel : class
        {
            return XoohooAntiForgeryToken(htmlHelper, htmlHelper.ViewData.Model as XoohooViewModel);
        }

        internal static MvcHtmlString XoohooAntiForgeryToken(this HtmlHelper htmlHelper, XoohooViewModel model)
        {
            if (model != null)
                return htmlHelper.AntiForgeryToken(model.Site.SiteID.ToString());

            return MvcHtmlString.Empty;
        }

        #endregion

    }
}
